﻿using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Scheduler.Model
{
    /// <summary>
    /// 用户信息表
    /// </summary>
    [Comment("用户信息表")]
    //[Table("user_info")]
    public class SysUserInfo : BaseEntity
    {
        //public SysUserInfo(string loginName, string loginPWD)
        //{
        //    LoginName = loginName;
        //    LoginPWD = loginPWD;
        //    RealName = LoginName;
        //    Status = 0;
        //    LastErrorTime = DateTime.Now;
        //    ErrorCount = 0;
        //}

        /// <summary>
        /// 登录账号
        /// </summary>
        [Comment("登录账号")]
        [StringLength(200)]
        [Required]
        public string? LoginName { get; set; }

        /// <summary>
        /// 登录密码
        /// </summary>
        [Comment("登录密码")]
        [StringLength(200)]
        [Required]
        public string? LoginPWD { get; set; }

        /// <summary>
        /// 真实姓名
        /// </summary>
        [Comment("真实姓名")]
        [StringLength(200)]
        [Required(ErrorMessage ="真实姓名不能为空！")]
        public string? RealName { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Comment("状态")]
        public int Status { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Comment("备注")]
        [StringLength(2000)]
        public string? Remark { get; set; }

        /// <summary>
        /// 关键业务修改时间
        /// </summary>
        [Comment("关键业务修改时间")]
        public DateTime CriticalModifyTime { get; set; } = DateTime.Now;

        /// <summary>
        ///最后异常时间 
        /// </summary>
        [Comment("最后异常时间")]
        public DateTime LastErrorTime { get; set; } = DateTime.Now;

        /// <summary>
        ///错误次数 
        /// </summary>
        [Comment("错误次数")]
        public int ErrorCount { get; set; }

        /// <summary>
        /// 性别 
        /// </summary>
        [Comment("性别")]
        public int Gender { get; set; }
        /// <summary>
        /// 出生日期
        /// </summary>
        [Comment("生日")]
        public DateTime BirthDate { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        [Comment("地址")]
        public string? Address { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        [Comment("是否启用")]
        public bool Enable { get; set; } = true;

        /// <summary>
        /// 角色名称
        /// </summary>

        [NotMapped]
        public List<string>? RoleNames { get; set; }
        /// <summary>
        /// 部门Id
        /// </summary>

        [NotMapped]
        public List<long>? Dids { get; set; }
        /// <summary>
        /// 部门名称
        /// </summary>

        [NotMapped]
        public string? DepartmentName { get; set; }
        /// <summary>
        /// 角色Id
        /// </summary>
        [NotMapped]
        public List<long>? RIDs { get; set; }
    }
}
